#include "stdafx.h"
#include "Button.h"


Button::Button(void)
{
	_btn.Create(L"NO", WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(), __pWnd, 0);
}


Button::~Button(void)
{
}


void Button::Serialize(CArchive& ar)
{
	Graphic::Serialize(ar);

	CRect   btnRect;
	CString btnCaption;

	if (ar.IsStoring())
	{	// storing code
		_btn.GetWindowRect(btnRect);
		btnRect.OffsetRect(2, -139);
		_btn.GetWindowText(btnCaption);
		ar << btnRect << btnCaption;
	}
	else
	{	// loading code
		ar >> btnRect >> btnCaption;
		_btn.MoveWindow(btnRect);
		_btn.SetWindowText(btnCaption);
	}
}


void Button::initPos(CPoint& pt1, CPoint& pt2)
{
	const CSize btnSize(60, 25);
	CRect btnRect(pt1, pt1 + btnSize);

	_btn.MoveWindow(btnRect);
}

